/*
时间组件
*/
import React, { useEffect, useState } from 'react'
const Time=()=> {
	useEffect(()=>{
		let timer=setInterval(getTime,1000)
		return ()=>{
			clearInterval(timer)
		}
	},[])
	const [MyData,setMyData]=useState("2020年01月01日 00:00:00")
	const getTime=()=>{
		const NewlyTime = new Date()
		let Year = NewlyTime.getFullYear()
		let Month = NewlyTime.getMonth()+1
		Month=Month>9?Month:"0"+Month;
		let Day = NewlyTime.getDate()
		Day=Day>9?Day:"0"+Day;
		let Hours = NewlyTime.getHours()
		Hours=Hours>9?Hours:"0"+Hours;
		let Minutes = NewlyTime.getMinutes()
		Minutes=Minutes>9?Minutes:"0"+Minutes;
		let Second = NewlyTime.getSeconds()
		Second=Second>9?Second:"0"+Second;
		console.log(NewlyTime, Year)
		setMyData(`${Year}年${Month}月${Day}日 ${Hours}:${Minutes}:${Second}`)
	}
	return (
		<div>{MyData}</div>
	)
}

export default Time